using System;
using System.Collections;
using System.Collections.Generic;
using Microsoft.MediaCenter.Hosting;
using Microsoft.MediaCenter.UI;

namespace MCEMediaManager
{
    public class CustomChoice : Choice
    {
        public CustomChoice(IModelItemOwner owner, string description, IList options) : base(owner, description, options)
        {
            this.PropertyChanged += new PropertyChangedEventHandler(CustomChoice_PropertyChanged);
        }

        public CustomChoice()
            : base()
        {
            this.PropertyChanged += new PropertyChangedEventHandler(CustomChoice_PropertyChanged);
        }

        public new IList Options
        {
            get
            {
                if (base.Options == null)
                {
                    return new ArrayListDataSet();
                }
                else
                    return base.Options;
            }
            set
            {
                if (value == null || value.Count == 0)
                {
                    this.Count = 0;
                }
                else
                {
                    base.Options = value;
                }
            }
        }

        protected override void ValidateOptionList(IList potentialOptions)
        {
            //base.ValidateOptionList(potentialOptions);
        }

        void CustomChoice_PropertyChanged(IPropertyObject sender, string property)
        {
            if (property == "Options")
            {
                FirePropertyChanged("Count");
            }
        }
        public int Count
        {
            get
            {
                if (Options != null)
                    return Options.Count;
                else
                    return 0;
            }
            set
            {
                FirePropertyChanged("Count");
            }
        }
        
    }
}
